#include<bits/stdc++.h>
using namespace std;
int solve() {
  int n,m,k;cin>>n>>m>>k;
  int a[n],b[m];
  for(auto&el:a)cin>>el;
  for(auto&el:b)cin>>el;
  sort(a,a+n);sort(b,b+m);
  int ans=0,i=0,j=0;
  while(i<n && j<m) {
    if(a[i]<b[j]-k) i++;
    else if(a[i]>b[j]+k) j++;
    else {ans++,i++,j++;}
  }
  cout<<ans<<endl;
  return 0;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  // freopen("in.txt","r",stdin);
  // freopen("out.txt","w",stdout);
  int tc; tc = 1;
  for(int t = 1; t <= tc; t++) {
    // cout << "Case #" << t << ": "
    solve();
  }
  return 0;
}
